import 'package:flutter_test/flutter_test.dart';
import 'package:qr_code_tools/widgets/page_state_table.dart';


void main() {
  test("PageStateTable.calTableCellSize", () {
    PageStateTable table = PageStateTable(state: List.filled(0, 0));
    double s = 0;
    List<List<int>> cases = [
      [180, 2, 360, 540],
      [360, 2, 360, 720],
      [100, 2, 360, 100],
      [180, 2, 360, 200],
      [180, 3, 360, 540],
      [180, 3, 360, 720],
      [100, 3, 360, 100],
      [120, 3, 360, 150],
      [180, 4, 360, 540],
      [180, 4, 360, 720],
      [70, 4, 360, 70],
      [90, 4, 360, 150],
      [180, 5, 360, 540],
      [180, 5, 360, 720],
      [50, 5, 360, 50],
      [72, 5, 360, 100],
      [72, 10, 360, 200],
      [120, 10, 360, 540],
      [25, 100, 360, 200],
      [36, 100, 360, 360],
    ];
    print("Test ${cases.length} cases...");
    for (List<int> c in cases) {
      s = table.calTableCellSize(c[1], c[2].toDouble(), c[3].toDouble());
      assert(s - c[0] < 1.0,
          "For ${c[1]}, ${c[2]}, ${c[3]}, expect ${c[0]}, but got $s");
    }
    print("Done.");
  });
}
